import { baseApiUrl, apiKey } from './dict.js'

export function request ({ address, method, params }) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: `${baseApiUrl}${address}`,
			method,
			data: {
				key: apiKey,
				...params
			},
			success: res => {
				if (res.statusCode === 200) {
					resolve(res)
				} else {
					reject()
				}
			},
			fail: () => {
				reject()
			}
		})
	})
}
